#include <iostream>
using namespace std;
int main()
{
	int n,k;
	int *arr;
	
	int QuickSelect(int *arr,int length,int theK);
	cin>>n>>k;
	arr=new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	
	int t= QuickSelect(arr,n,k);
	cout<<t;
	
	return 0;
}

struct Nums
{
	int *s;
	int *e;
};

int QuickSelect(int *arr,int length,int theK)
{
	int Devide(int *arr,int *arr1,int *arr2,int length,int base);
	void IfDelete(int *x);
	int *arr1;
	int *arr2;
	int base=0;
	while(1)
	{
		int t=Devide(arr,arr1,arr2,length,base);
		if(t==theK)
		{
			int ax=arr[0];
			IfDelete( arr);
			IfDelete (arr1);
			IfDelete (arr2);
			return ax;
		}
		else
		{
			if(t<theK)
			{
				IfDelete (arr2);
				arr=arr1;
				arr1=NULL;
				length=t-1;
			}
			else
			{
				IfDelete (arr1);
				arr=arr2;
				arr2=NULL;
				length-=(t+1);
				base+=t;
			}
		}
	}
	return -1;
}

int Devide(int *arr,int *arr1,int *arr2,int length,int base)
{
	
	
	arr1=new int[length-1];
	arr2=new int[length-1];
	
	int a=0,b=0;
	for(int i=1;i<length;i++)
	{
		if(arr[0]>=arr[i])
		{
			arr1[a++]=arr[i];
		}else
		{
			arr2[b++]=arr[i];
		}
	}
	
	return base+b;
}

/*
int SetMiddle(int x[],int length)
{
void Swap(int *a,int *b);
int i,a,b;
i=0; a=1;b=1;

  while(true)
  {
		for(;x[a]>=x[i]&&a<length;a++)
		{
		}
		
		  for(;x[b]<x[i]&&b<length;b++,a++)
		  {
		  }
		  
			if(a==length)
			{break;}
			Swap(&x[a],&x[b]);
			
			  }
			  return b ;
			  }
*/
void Swap(int *a,int *b)
{
	int t=*a;
	*a=*b;
	*b=t;
}

 void IfDelete(int *x)
 {
	 if(x!=NULL)
	 {
		 delete x;
	 }else
	 {
		 printf("null");
	 }
 }